<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
<div style="background-color: #2ca02c">
    @if(count($errors)>0)
        @if(is_object($errors))
            @foreach($errors->all() as $error)
                <p>{{$error }}</p>
            @endforeach
        @else
            {{$errors}}
        @endif

    @endif
</div>
<div style="text-align: center">
    <h1>祝孟港的管理系统</h1>
</div>

<form method="post">
    <div style="padding-left: 100px;padding-bottom: 20px">
        <h2>快捷导航</h2>
        <a href="{{url('Admin/links/create')}}">添加</a>
        <a href="{{url('Admin/links')}}">更新</a>
    </div>

    <table border="1px" width="60%"style="padding-left: 20px;color: red">
        <tr>
            <th width="5%">排序</th>
            <th width="5%">ID</th>
            <th width="5%">标题</th>
            <th width="5%">名称</th>
            <th width="5%">链接</th>

            <th width="5%">操作</th>


        </tr>

        @foreach($linkresoult as $y)
            <tr>
                <td>
                    <input type="text" onchange="order(this,{{$y->link_id}}) " name="order[]" value="{{$y->link_order}}"
                    style="margin-left: 20px;width: 50px;height: 20px"
                    />

                </td>

                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{$y->link_id}}</td>
              <td>{{$y->link_name }}</td>
                <td>{{$y->link_title}}</td>
                <td>{{$y->link_url}}</td>



                <td>&nbsp;<a href="{{url('Admin/links/'.$y->link_id.'/edit')}}">修改</a>&nbsp;&nbsp;
                    <a href="javascript::" onclick="artdel({{$y->link_id}})">删除</a></td>
            </tr>


        @endforeach
    </table>
    <div id="fen">
        {{$linkresoult->links()}}
    </div>

</form>
{{--<style>

    div {
        display: inline;
    }
    ul, menu, dir {
        display: block;
        list-style-type: disc;
        -webkit-margin-before: 1em;
        -webkit-margin-after: 1em;
        -webkit-margin-start: 0px;
        -webkit-margin-end: 0px;
        -webkit-padding-start: 40px;
    }
</style>--}}


<script type="text/javascript" src="{{asset('resources/views/Admin/js/jquery-3.1.1.min.js')}}">
</script>
<script type="text/javascript" src="{{asset('resources/views/org/layer/layer.js')}}">
</script>

<script>
    function order(obj,link_id ){
        var linkorder=$(obj).val();
        $.post("{{url('Admin/links/order')}}",{'_token':'{{csrf_token()}}','linkorder':linkorder,'link_id':link_id},function (date) {

            if (date.status==1){
               /* location.href=location.href;*/
                layer.alert(date.msg, {icon: 6});
            }else {
            layer.msg(date.msg, {icon: 5});
        }
        });
    }

    function artdel(link_id){
        layer.confirm('你确定删除这篇文章吗？', {
            btn: ['是的','取消']
        }, function(){
            $.post("{{url('Admin/links/')}}/"+link_id,{'_method':'delete','_token':'{{csrf_token()}}'},function (update) {
                     if(update.status==1){
                   location.href=location.href;
                         layer.alert(update.msg, {icon: 6});
                     }else {
                         layer.msg(update.msg, {icon: 5});
                     }
            });


        }, function(){

        });
    }
</script>
</body>
</html>